<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			// 统计字符串中每个字符的个数？以对象的形式返回
			var str = 'abcdacbabcbababcbabcabd';
		/* 	var res = str.split('');
			var res1 = res.reduce(function(pre, cur) {
				if(cur in pre){
					pre[cur]+=1;
				}else{
					pre[cur]=1
				}
					return pre 
			}, {})
			 */
			//不转数组方法v
			var obj={};
			
			for(var i=0;i<str.length ;i++){
				if(str[i] in obj){
				
				obj[str[i]] +=1;
				
			}else{
				obj[str[i]]=1;
			}
			}
		</script>
	</body>
</html>
